﻿<%@ Page Title="广告位列表页" Language="C#" MasterPageFile="~/MasterPage/Main.master" AutoEventWireup="true" CodeFile="advertList.aspx.cs" Inherits="advert_advertList" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<asp:Content ID="Content1" ContentPlaceHolderID="headcss" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<div class="ListHead">
    <h3>Advert List</h3>
</div>
<table style="width: 100%;" class="queryTable">
    <tr>
    <td colspan="2">    
        <input id="btnAdd" class="btn" onclick="addAdvert(<%=SpaceID %>);return false;" type="button" value="新增广告" />
     </td>
    </tr>
    <tr>
    <td style="width: 6%;">    
        <input  class="btn" onclick="ChangeStatus('true');" type="button" value="启用" />
     </td>
    <td>    
        <input  class="btn" onclick="ChangeStatus('false');" type="button" value="禁用" />
     </td>
    </tr>
</table>
<table cellpadding="0" cellspacing="1" border="0" class="TableList">
    <tr>
        <th style="width: 3%;"><input type="checkbox" id="check_all" /></th>
        <th style="width: 11%;">广告名称</th>
        <th style="width: 11%;">广告位名称</th>
        <th style="width: 11%;">关键字</th>
        <th style="width: 12%;">有效期</th>
        <th style="width: 10%;">广告显示类型</th>
        <th style="width: 10%;">创建时间</th>
        <th style="width: 12%;">当前状态</th>
        <th style="width: 6%;">排序</th>
        <th style="width: 24%;">操作</th>
    </tr>
    <tr>
        <td></td>
        <td><asp:TextBox ID="txtAdvrtName" MaxLength="150" runat="server" Width="90%" CssClass="textbox"></asp:TextBox></td>
        <td><asp:TextBox ID="txtSpaceName" MaxLength="150" runat="server" Width="90%" CssClass="textbox"></asp:TextBox></td>
        <td><asp:TextBox ID="txtKey" MaxLength="150" runat="server" Width="90%" CssClass="textbox"></asp:TextBox></td>
        <td>
        <asp:TextBox ID="txtStartTime" MaxLength="20" runat="server" Width="90%" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" CssClass="textbox"></asp:TextBox>
        <asp:TextBox ID="txtEndTime" MaxLength="20" runat="server" Width="90%" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" CssClass="textbox"></asp:TextBox></td>
        <td>
        <asp:DropDownList ID="ddpAdvertType" runat="server" Width="100%" CssClass="select">
                <asp:ListItem Selected="True" Value="-8">Please Select</asp:ListItem>
                <asp:ListItem Value="1">文字广告</asp:ListItem>
                <asp:ListItem Value="2">图片广告</asp:ListItem>
                <asp:ListItem Value="3">Flash广告</asp:ListItem>
                <asp:ListItem Value="4">文字滚动广告</asp:ListItem>
                <asp:ListItem Value="5">图片滚动广告</asp:ListItem>
            </asp:DropDownList>
        </td>
        <td></td>
        <td>
        <asp:DropDownList ID="ddpStatus" runat="server" Width="90%" CssClass="select">
                <asp:ListItem Selected="True" Value="-8">Please Select</asp:ListItem>
                <asp:ListItem Value="0">未启用</asp:ListItem>
                <asp:ListItem Value="2">启用</asp:ListItem>
                <asp:ListItem Value="3">已生效</asp:ListItem>
                <asp:ListItem Value="5">即将到期</asp:ListItem>
                <asp:ListItem Value="-1">到期</asp:ListItem>
            </asp:DropDownList></td>
        <td></td>
        <td><asp:Button ID="btnSerach" CssClass="btn" class="btn" OnClick="btnSerach_Click" runat="server"  Text="筛选" /></td>
    </tr>
    <%if (AdvertList != null && AdvertList.Count > 0)
      { %>
    <%foreach (var advert in AdvertList)
      { %>
    <tr>
        <td><input class="checkbox" type="checkbox" id="check_<%=advert.ID %>" name="checkAdverts" value="<%=advert.ID %>" /></td>
        <td><%=advert.AdvertName%></td>
        <td><%=advert.SpaceName%></td>
        <td><%=advert.KeyWords%></td>
        <td><%=advert.BeginTime%><br /><%=advert.EndTime%></td>
        <td><%=advert.AdvertType%></td>
        <td><%=advert.CreateDate%></td>
        <td><%=advert.Status%></td>
        <td><%=advert.OrderBy%></td>
        <td style="text-align:center;"><a href="advertView.aspx?id=<%=advert.ID %>" target="_blank">查看</a>&nbsp;&nbsp;
        <a href="javascript:" onclick="openDetail(<%=advert.ID %>)">编辑</a>&nbsp;&nbsp;
        <a href="javascript:" onclick="changeOrder(<%=advert.ID %>,1)">上</a>&nbsp;&nbsp;
        <a href="javascript:" onclick="changeOrder(<%=advert.ID %>,-1)">下</a>&nbsp;&nbsp;
        <a href="javascript:" onclick="deleteAdvert(<%=advert.ID %>)">删除</a></td>
    </tr>
    <%} %>
    <%} %>
</table>
<table style="width: 100%;" id="tblfoot" runat="server">
    <tr>
        <td style="width: 60%;">
            <webdiyer:AspNetPager ID="AspNetPager1" OnPageChanged="AspNetPager1_PageChanged"
                runat="server" PageIndexBoxType="DropDownList" ShowPageIndexBox="Always" AlwaysShow="True">
            </webdiyer:AspNetPager>
        </td>
        <td>
            总条数：<%=AspNetPager1.RecordCount%>
        </td>
        <td>
            总页数：<%=AspNetPager1.PageCount%>
        </td>
        <td>
            每页显示：<asp:DropDownList ID="ddlPageCount" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddlPageCount_SelectedIndexChanged">
                <asp:ListItem Value="5">5</asp:ListItem>
                <asp:ListItem Value="10" Selected="True">10</asp:ListItem>
                <asp:ListItem Value="30">30</asp:ListItem>
                <asp:ListItem Value="50">50</asp:ListItem>
                <asp:ListItem Value="100">100</asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
</table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" Runat="Server">
<script src="/js/common/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script>
<script type="text/javascript">
    function addAdvert(SpaceID, BoardID) {
        window.open("advertDetail.aspx?Action=add&SpaceID=" + SpaceID);
    }
    function openDetail(Id) {
        window.open("advertDetail.aspx?Action=edit&ID=" + Id);
    }
    function deleteAdvert(id) {
        if (confirm("Are You Sure?")) {
            $.post("advertDelete.ashx", { advertID: id }, function (rValue) {
                if (rValue != "-1") {
                    window.location.href = window.location.href;
                }
            });
        }
    }
    function changeOrder(id, Step) {
        $.post("changeAdvertOrder.ashx", { advertID: id, step: Step }, function (rValue) {
            if (rValue != "-1") {
                window.location.href = window.location.href;
            }
        });
    }
</script>
</asp:Content>

